package edu.xust.web.controller;

import edu.xust.config.*;
import edu.xust.dto.BaseDto;
import edu.xust.entity.PsManager;
import edu.xust.page.PageInfo;
import edu.xust.service.PsManagerService;

import java.util.Date;

@Controller("/psManagerController")
public class PsManagerController {
    @Resource
    PsManagerService psManagerService;

    @RequestMapping("/getPsManagerByPage")
    @ResponseBody
    public BaseDto getPsManagerByPage(@RequestBody PageInfo pageInfo) throws Exception {
        return psManagerService.getPsManagerByPage(pageInfo);
    }

    @RequestMapping("/getPsManagerByPid/{id}")
    @ResponseBody
    public BaseDto getPsManagerByPage(String pid) throws Exception {
        return psManagerService.getPsManagerByPid(pid);
    }

    @RequestMapping("/addPsManager")
    @ResponseBody
    public BaseDto addPsManager(@RequestBody PsManager psManager){
        Date date = new Date();
        psManager.setPmPwd("123456");
        psManager.setPmCreatetime(date);
        psManager.setPmLastlogin(date);
        psManager.setPmStatus("N");
        return psManagerService.addPsManager(psManager);
    }

    @RequestMapping("/updatePsManager")
    @ResponseBody
    public BaseDto updatePsManager(@RequestBody PsManager psManager){
        return psManagerService.updatePsManager(psManager);
    }
}
